<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/frame.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl;?>/files/admin/css/frame.css">
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
</head>
<style>
.selApp{ background: #CCCCCC;  border-left:1px solid #484848;}
</style>
<body>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/select.jquery/select.css" />
<script type="text/javascript">
	$(document).ready(function() {
		$(".dropdown img.flag").addClass("flagvisibility");

		$(".dropdown dt a").click(function() {
			$(".dropdown dd ul").toggle();
		});

		$(".dropdown dd ul li a").click(function() {
			var text = $(this).html();
			//$(".dropdown dt a span").html(text);
			$(".dropdown dd ul").hide();
			//dm add
			code =$(this).find('span');
			stringObj = $(this).text();
			newStr = stringObj.replace(code.text(),""); 
			$("#currentProductCode").val(newStr);
		});

		function getSelectedValue(id) {
			return $("#" + id).find("dt a span.value").html();
		}

		$(document).bind('click', function(e) {
			var $clicked = $(e.target);
			if (! $clicked.parents().hasClass("dropdown")){
				$(".dropdown dd ul").hide();
				//dm add
				$("#currentProductCode").val('<?php echo trim($this->currentProductName) != '' ? $this->currentProductName : '未选择产品';?>');
				}
				
		});


		$("#flagSwitcher").click(function() {
			$(".dropdown img.flag").toggleClass("flagvisibility");
		});
	});
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" height="100%" id="main">
	<tr>
		<td height="9%" colspan="2" id="top" valign="top">
			<div id="logo"><img src="<?php echo $this->baseUrl;?>/files/admin/images/logo.png" border="0"></div>
			<div id="userInfo">
				<p>
			  <div id="userName"><?php echo $this->currentUserRow['userName'];?>（<?php echo $this->currentUserRow['name'];?>）， 角色：
						<span id="roleBlock" >
							<span id="userRole" class="more"><?php echo $this->currentRoleName === NULL ? '暂无角色' : $this->currentRoleName;?> <?php if (count($this->myRoleRows) > 1) {?><img src="<?php echo $this->baseUrl;?>/files/admin/images/expand.gif" align="absmiddle"/><?php }?></span>
							<div id="roleMenu">
								<div>
<?php
foreach($this->myRoleRows as $key=>$myRoleRow) {
?>
							<a href="<?php echo $this->projectUrl(array('action'=>'change-role', 'roleId'=>$myRoleRow['id']));?>"><?php echo $myRoleRow['name'];?></a> 
<?php
}
?>
								</div>
							</div>
						</span>
			  </div>
				</p>
<script language="javascript">
<?php if (count($this->myRoleRows) > 1) {?>
$("#roleBlock").hover(function(){
	$("#roleMenu").show();
}, function(){
	$("#roleMenu").hide();
});
<?php }?>
</script>
				<div class="cl"></div>
				<p>
					<a href="<?php echo $this->projectUrl(array('controller' => 'user', 'action' => 'update-self-password')) ;?>" target="rightFrame">修改密码</a>
<?php if (in_array($this->currentUserRow['userName'], $this->master['developer'])){?>
					| <a href="<?php echo $this->projectUrl(array('controller' => 'menu', 'action' => 'index')) ;?>" target="rightFrame">菜单管理</a> 
<?php
}
?>
<?php if (in_array($this->currentUserRow['userName'], $this->master['developer']) || in_array($this->currentUserRow['userName'], $this->master['common'])){?>
					| <a href="<?php echo $this->projectUrl(array('controller' => 'product-menu', 'action' => 'index')) ;?>" target="rightFrame">产品菜单管理</a>
<?php
}
?>
					| <a href="<?php echo $this->projectUrl(array('controller' => 'login', 'action' => 'logout')) ;?>">退出登录</a></p>
			</div>
			<div id="other">
				<p id="otherLink"><a href="<?php echo $this->projectUrl();?>">平台首页</a> | <a href="#">帮助中心</a></p>
				<p id="appSelect">
<?php
if (count($this->myProductRows) > 0) {
?>
				<dl class="dropdown">
						<dt><a href="javascript:void(0);"><input name="currentProductCode" id="currentProductCode" type="text" value="<?php echo trim($this->currentProductName) != '' ? $this->currentProductName : '未选择产品';?>" style="width:100px; border:0;cursor:pointer; padding:3px 0 0 3px;color:#816c5b;" onFocus="$('#currentProductCode').val('');" onKeyUp="keyup(event)"   autocomplete="off" />
						</a></dt>
						<dd>
							<ul>
<?php
	foreach($this->myProductRows as $myProductRow) {
?>
								<li class="<?php echo $myProductRow['code'];?>"><a href="<?php echo $this->projectUrl(array('action'=>'change-product', 'productCode'=>$myProductRow['code']));?>"><?php echo $myProductRow['name'];?><span class="value"><?php echo $myProductRow['code'];?></span></a></li>
<?php
	}
?>
							</ul>
						</dd>
				</dl>
<?php
} else {
?>
					
<?php
}
?>
				</p>
			</div>		
			</td>
	</tr>
	<tr id="bottom">
		<td width="20%" align="right" valign="top">
			<div id="menu">
				<div id="menu_bg">
					<div id="menu_ee_bg">
						<div class="menu_bg_top"><img src="<?php echo $this->baseUrl;?>/files/admin/images/menu_e_top.png" /></div>
						<div class="menu_bg_mid">
							<div class="menu_main_left"><img src="<?php echo $this->baseUrl;?>/files/admin/images/menu_e_left.png" /></div>
							<div class="menu_main_main">
								<div class="menu_main_bg">
								<?php echo $this->listContent;?>
								</div>
							</div>
							<div class="menu_main_right"><img src="<?php echo $this->baseUrl;?>/files/admin/images/menu_e_right.png" /></div>
						</div>
						<div id="menu_bg_foot"><img src="<?php echo $this->baseUrl;?>/files/admin/images/menu_e_foot.png" /></div>
					</div>
				</div>
			</div>
		</td>
		<td id="right">
			<iframe src="<?php echo $this->projectUrl(array('controller'=>'index', 'action'=>'right'));?>" name="rightFrame" width="100%" height="100%" frameborder="0" id="rightFrame"></iframe>
		</td>
	</tr>
</table>

<script language="javascript">
$("#menu p").click(function(){
	if ($(this).next().css('display') == 'none') {
		$(this).next().show();


		if ($(this).attr('class').search(/menuHaveChild/) != -1) {
			$(this).removeClass('menuHaveChild');
			$(this).addClass('menuHaveChildExp');
		}
	} else {
		$(this).next().hide();
		if ($(this).attr('class').search(/menuHaveChildExp/) != -1) {
			$(this).removeClass('menuHaveChildExp');
			$(this).addClass('menuHaveChild');
		}
	}
	
	if ($(this).attr('class').search(/menuHaveChild/) == -1 && $(this).attr('class').search(/menuHaveChildExp/) == -1) {
		$("#menu p").css({color:'#000'});
		$("#menu p").find('a').css({'color':'#000', 'text-decoration':'none'});
		$(this).find('a').css({color:'#00f', 'text-decoration':'underline'});
	}
});
</script>

<script language="javascript">
var updateTime = (<?php echo $this->effectiveOnlineTime;?> - 3) * 1000;//状态更新时间，默认要比在线时间小
function online()
{

    var url = '<?php echo $this->projectUrl(array('controller'=>'online', 'action'=>'index'));?>' + '?rand/' + Math.random();

	$.ajax({
		type: "POST",
		url: url,
		dataType: "json",
		async: true,
		success: function(result){
			if (result.status != 0) {
				alert(result.message);
				location.href = '<?php echo $this->projectUrl(array('controller'=>'login', 'action'=>'logout'));?>';
			}
			setTimeout(online, updateTime);
		} 
	});
}
setTimeout(online, updateTime);


//find app
function keyup(event){
    if(window.event){
    	var key =window.event.keyCode;
    }else{    
		var key =event.which;
    }
	//show 
	$(".dropdown dd ul").show();
    if(key!=38&&key!=40&&key!=13){
     	var kw=$("#currentProductCode").val();
		//remove
		$('.dropdown dd ul li').find("a").removeClass('selApp');
		//find productCode
		/*$('.dropdown dd ul li').find("span").each(function(){
		  $(this).toggle(function(){
				// 操作
				var element = $(this).text();
				re = eval('/^('+kw+')+/gi');
				if ($.trim(kw)!=''&&element.match(re)){
					 $('.dropdown dd ul li.'+$(this).text()).find("a").addClass('selApp');
				}
		  });
		});*/
		//find productCode or appName
		$('.dropdown dd ul li a').each(function(){
			// 操作
			codeElement = $(this).find('span');
			code = codeElement.text();
			stringObj = $(this).text();
			newStr = stringObj.replace(code,""); 
			re = eval('/^('+kw+')+/g');
			if ($.trim(kw)!=''&& (newStr.match(re)||code.match(re))){
				 $('.dropdown dd ul li.'+code+' a').addClass('selApp');
			}
		});
		
    }
}
</script>
</body>
</html>